package test3;

public class Demo3 {
    public static void main(String[] args) {
        Musician m=new Musician();
        Instrument e = new Erhu();
        Instrument p = new Piano();
        Instrument v = new Violin();
        m.play(e);
        m.play(p);
        m.play(v);
    }
}
class Instrument{
    public void  makeSound(){
        System.out.println("发出声音");
    }
}
class Erhu extends Instrument{
    public void  makeSound(){
        super.makeSound();
        System.out.println("二胡声音");
    }
}
class Piano extends Instrument{
    public void  makeSound(){
        super.makeSound();
        System.out.println("钢琴声音");
    }
}
class Violin extends Instrument{
    public void makeSound(){
        super.makeSound();
        System.out.println("小提琴声音");
    }
}
 class Musician{
    public void play(Instrument i){
        i.makeSound();
    }
}
